<?php

class Workset_Form_Decorator_Button extends Zend_Form_Decorator_Abstract {

    const SEPARATOR = '';

    function render($content) {
        $element = $this->getElement();
        $options = $this->getOptions();

        if (!isset($options['type'])) {
            return $content;
        }

        $html = $this->_renderButton($options);

        if (isset($options['tag']) && isset($options['class'])) {
            $tag = new Zend_Form_Decorator_HtmlTag(array(
                'tag' => $options['tag'],
                'class' => $options['class']
            ));

            $html = $tag->render($html);
        }

        return $content.$html;
    }

    protected function _renderButton($options = array()) {
        $html = '';

		$action = isset($options['action']) ? $options['action'] : '#';
		$title = isset($options['label']) ? $options['label'] : '';

        switch (strtolower($options['type'])) {
            case 'del':

                $html = '<a rel="delete" class="link_button ui-state-default ui-corner-all" href="'.$action.'"><span class="ui-icon ui-icon-close"/>'.($title).'</a>';
            break;

            case 'add':
                $html = '<a rel="multiple" href="#" class="link_button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plus"></span>'.($title).'</a>';
            break;
        }

        return $html;
    }
    
}

?>